<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Progressive Play Server
 * Stats Controller
 * /controllers/stats.php
 * By: Yukwunhang
 */
class Stats extends MY_Controller
{
	// Constructor.
	function Stats()
	{
		parent::MY_Controller();
	}
	
	// Individual player stats
	function player()
	{
		// Get player stats
		$pid = $this->uri->segment(3);
		$this->load->model('player_model', 'player');
		$this->data['stats'] = $this->player->get_player_stats_by_id($pid);
		// Get Accuracy Stats
		$this->data['stats']['acc'] = $this->player->get_acc_by_id($pid);
		
		// Check for existance
		if (!$this->data['stats'])
		{
			show_error('The player you requested does not exist.');
		}
		
		// Load view, render.
		$this->template->write('title', $this->data['stats']['name'].' | Player Stats | Progressive Play Server');
		$this->template->write_view('content', 'player/player_stats_table_view', $this->data);
		$this->template->render();
	}
	
	// Top users of individual weapons
	function weapon()
	{
		// What weapon?
		// Change 'url safe' weapon name to 'normal' name
		$this->data['weapon'] = str_ireplace('_', ' ', $this->uri->segment(3));
		
		// Set up
		$row = 10; // Number of users shown
		$offset = 0; // Offset
		
		// Get stats
		$this->load->model('weapon_model', 'weapon');
		$this->data['stats'] = $this->weapon->get_top_weapon_users($this->data['weapon'], $row, $offset);
		
		// Check for existence
		if (!$this->data['stats'])
		{
			show_error('The weapon you requested does not exist.');
		}
		
		// Load view, render, boom.
		$this->template->write('title', $this->data['weapon'].' | Stats | Progressive Play Server');
		$this->template->write_view('content', 'weapon/top_weapon_users_table_view', $this->data);
		$this->template->render();
	}
}
/*
 * End of file
 */